segregate even and odd numbers in an array and sorting